<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>{$Think.lang.artlst}</title>
    <link rel="stylesheet" href="__ADMIN__/vendor/layui/css/layui.css">
    <link rel="stylesheet" href="__ADMIN__/custom/css/style.css">
</head>

<body style="padding:10px 10px;">
    <form class="layui-form" action="{:url('article/deleteAll')}" method="post">
        <div>
            <a href="{:url('article/create')}" class="layui-btn layui-btn-normal">{$Think.lang.add}</a>
            <button type="submit" class="layui-btn layui-btn-danger">{$Think.lang.pldel}</button>
            <div class="layui-form-item" style="float: right;">
                <label class="layui-form-label">{$Think.lang.cloumn}</label>
                <div class="layui-input-inline">
                    <select name="cid" lay-filter="lanmu">
                        <option value="0">{$Think.lang.select}</option>
                        {volist name="cate" id="vo"}
                        <option value="{$vo.id}" {if condition="$cid eq $vo['id']"}selected{/if}>{$vo.cate_name}</option>
                        {/volist}
                    </select>
                </div>
            </div>
            <table class="layui-table" lay-size="md">
                <colgroup>
                    <col width="60">
                    <col width="80">
                    <col>
                    <col width="100">
                    <col width="200">
                    <col width="100">
                    <col width="100">
                    <col width="100">
                    <col width="220">
                </colgroup>
                <thead>
                    <tr style="height: 45px" pid="0">
                        <th style="text-align:center;"><input type="checkbox" name="" lay-skin="primary"
                                lay-filter="quanxuan"></th>
                        <th style="text-align: center;">ID</th>
                        <th>{$Think.lang.title}</th>
                        <th>{$Think.lang.cloumn}</th>
                        <th>{$Think.lang.addtime}</th>
                        <th style="text-align: center;">{$Think.lang.ywtp}</th>
                        <th style="text-align: center;">{$Think.lang.click}</th>
                        <th style="text-align: center;">{$Think.lang.isshow}</th>
                        <th>{$Think.lang.caoz}</th>
                    </tr>
                </thead>
                <tbody>

                    {volist name="art" id="vo"}
                    <tr>
                        <td style="text-align: center;"><input type="checkbox" name="id[]" class="qx" lay-skin="primary"
                                value="{$vo.id}"></td>
                        <td style="text-align: center;">{$vo.id}</td>
                        <td>{$vo.title}</td>
                        <td>{$vo.cate_name}</td>
                        <td>{$vo.addtime|date="Y--m-d H:i:s",###}</td>
                        <td style="text-align: center;">
                            {if condition="$vo.pic eq 0"}
                            无图
                            {else}
                            有图<span class="layui-badge">{$vo.pic}</span>张
                            {/if}
                        </td>
                        <td style="text-align: center;">{$vo.views}</td>
                        <td style="text-align: center;"><input type="checkbox" name="istop" lay-filter="istop"
                                lay-skin="switch" lay-text="确认|取消" value="{$vo.id}" {eq name="$vo.istop" value="1"
                                }checked {/eq}> </td> <td>
                            <botton class="layui-btn layui-btn-mini {eq name=" $vo.pic" value="0"
                                }layui-btn-disabled{/eq} tupian" id="{$vo.id}"><i class="layui-icon">&#xe64a;</i>
                            </botton>
                            <a href="{:url('article/edit',['id'=>$vo['id']])}"
                                class="layui-btn layui-btn-warm layui-btn-mini"><i class="layui-icon">&#xe642;</i></a>
                            <a href="{:url('article/delete',['id'=>$vo['id']])}"
                                class="layui-btn layui-btn-danger layui-btn-mini del"><i
                                    class="layui-icon">&#xe640;</i></a>
                        </td>
                    </tr>
                    {/volist}
                </tbody>
            </table>
            <div style="text-align: right;">{$art->render()}</div>
        </div>
    </form>

    <script src="__ADMIN__/vendor/js/jquery.js"></script>
    <script src="__ADMIN__/vendor/layui/layui.js"></script>
    <script src="__ADMIN__/custom/js/admin.js"></script>
    <script>
        layui.use(['layer', 'form'], function () {
            var layer = layui.layer;
            var form = layui.form;

            $('.del').on('click', function () {
                var url = $(this).attr('href');
                layer.confirm('确认删除吗', { icon: 3, title: '温馨提示' }, function (index) {
                    //do something
                    location.href = url;
                    layer.close(index);
                });
                return false;
            });
            // 置顶功能/监听开关
            form.on('switch(istop)', function (data) {
                var aid = data.value;
                var istop = data.elem.checked;
                $.post("{:url('article/roof')}", { aid: aid, istop: istop }, function (res) {
                    layer.msg(res.msg, { time: 500 }, function (msg) {
                        location.href = "{:url('admin/article/index')}";
                    });
                })
            });
            // 监听栏目
            form.on('select(lanmu)', function (data) {
                var cid=data.value;
                location.href = "{:url('admin/article/index')}?cid="+cid;
            });
            // 全选与取消
            form.on('checkbox(quanxuan)', function (data) {
                if (data.elem.checked) {
                    $('.qx').prop("checked", "checked");
                    form.render();
                } else {
                    $('.qx').prop("checked", "");
                    form.render();
                }

            });
            // 图片点击事件
            $(".tupian").click(function () {
                var aid = $(this).attr("id");
                if ($(this).hasClass('layui-btn-disabled')) {
                    return false;
                }
                layer.open({
                    type: 2,
                    title: '内容图片',
                    area: ['700px', '450px'],
                    fixed: false, //不固定
                    maxmin: true,
                    content: '{:url("article/piclist")}?aid=' + aid //数组第二项即吸附元素选择器或者DOM
                });
            });


        });

        $(function () {
            $(window.parent.document).find('#righttitle').text($('title').text());
        });
    </script>
</body>

</html>